﻿using System;
using System.Collections.Generic;
using System.Text;
using Vortex.Drawing;

namespace Vortex.SceneFramework {

	/// <summary>
	/// ContentElement is a base class for other content element which supports blending, color and opacity properties
	/// </summary>
	public abstract class ContentElement : Node {
		private Blending _blending = Blending.Normal;
		private ColorU _color = ColorU.Blank;
		private float _opacity = 1f;

		protected ContentElement() {
			Color = ColorU.Blank;
			Opacity = 1f;
		}

		/// <summary>
		/// Gets or sets the blending of element content.
		/// </summary>
		/// <value>The blending of element content.</value>
		public virtual Blending Blending { 
			get { return _blending; }
			set { _blending = value; }
		}

		/// <summary>
		/// Gets or sets the color of element content.
		/// </summary>
		/// <value>The color of element content.</value>
		public virtual ColorU Color { 
			get { return _color; }
			set { _color = value; }
		}

		/// <summary>
		/// Gets or sets the opacity of element content.
		/// </summary>
		/// <value>The opacity of element content.</value>
		public virtual float Opacity { 
			get { return _opacity; }
			set { _opacity = Math.Min(Math.Max(value, 0f), 1f); }
		}

		/// <summary>
		/// Gets the combined color (int and opacity) of contents .
		/// </summary>
		/// <value>The combined color of the content.</value>
		protected ColorU ContentColor {
			get {
				float opacity = Opacity;
				return opacity < 1f ? Color.MultiplyAlpha(opacity) : Color;
			}
		}
	}
}
